Detangle compute_size, among other things.
{
}
-
static gboolean
gdk_wayland_drag_surface_compute_size (GdkSurface *surface)
{
static void
gdk_wayland_drag_surface_class_init (GdkWaylandDragSurfaceClass *class)
{
- GdkSurfaceClass *impl_class = GDK_SURFACE_CLASS (class);
+ GdkSurfaceClass *surface_class = GDK_SURFACE_CLASS (class);
- impl_class->compute_size = gdk_wayland_drag_surface_compute_size;
+ surface_class->compute_size = gdk_wayland_drag_surface_compute_size;
}
static void
int height,
GdkPopupLayout *layout);
-void configure_popup_geometry (GdkWaylandPopup *popup);
void gdk_wayland_surface_configure_popup (GdkWaylandPopup *popup);
void frame_callback_popup (GdkWaylandPopup *popup);
void gdk_wayland_popup_hide_surface (GdkWaylandPopup *popup);
}
}
-void
-configure_popup_geometry (GdkWaylandPopup *wayland_popup)
+static gboolean
+gdk_wayland_popup_compute_size (GdkSurface *surface)
{
- GdkWaylandSurface *wayland_surface = GDK_WAYLAND_SURFACE (wayland_popup);
- int x, y;
- int width, height;
+ GdkWaylandPopup *wayland_popup = GDK_WAYLAND_POPUP (surface);
+ GdkWaylandSurface *wayland_surface = GDK_WAYLAND_SURFACE (surface);
- x = wayland_popup->next_layout.x - wayland_surface->shadow_left;
- y = wayland_popup->next_layout.y - wayland_surface->shadow_top;
- width =
- wayland_surface->next_layout.configured_width +
- (wayland_surface->shadow_left + wayland_surface->shadow_right);
- height =
- wayland_surface->next_layout.configured_height +
- (wayland_surface->shadow_top + wayland_surface->shadow_bottom);
+ if (wayland_surface->next_layout.surface_geometry_dirty)
+ {
+ int x, y, width, height;
- gdk_wayland_surface_move_resize (GDK_SURFACE (wayland_popup), x, y, width, height);
+ x = wayland_popup->next_layout.x - wayland_surface->shadow_left;
+ y = wayland_popup->next_layout.y - wayland_surface->shadow_top;
+ width = wayland_surface->next_layout.configured_width +
+ (wayland_surface->shadow_left + wayland_surface->shadow_right);
+ height = wayland_surface->next_layout.configured_height +
+ (wayland_surface->shadow_top + wayland_surface->shadow_bottom);
+
+ gdk_wayland_surface_move_resize (surface, x, y, width, height);
+
+ wayland_surface->next_layout.surface_geometry_dirty = FALSE;
+ }
+
+ return FALSE;
}
void
gdk_wayland_popup_class_init (GdkWaylandPopupClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
+ GdkSurfaceClass *surface_class = GDK_SURFACE_CLASS (class);
object_class->get_property = gdk_wayland_popup_get_property;
object_class->set_property = gdk_wayland_popup_set_property;
+ surface_class->compute_size = gdk_wayland_popup_compute_size;
+
gdk_popup_install_properties (object_class, 1);
}
GdkRectangle last_sent_window_geometry;
- int saved_width;
- int saved_height;
-
struct {
gboolean is_initial_configure;
uint32_t serial;
gdk_wayland_surface_init (GdkWaylandSurface *impl)
{
impl->scale = 1;
- impl->saved_width = -1;
- impl->saved_height = -1;
}
void
gdk_wayland_surface_configure (surface);
}
-void
-_gdk_wayland_surface_save_size (GdkSurface *surface)
-{
- GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
-
- if (surface->state & (GDK_TOPLEVEL_STATE_FULLSCREEN |
- GDK_TOPLEVEL_STATE_MAXIMIZED |
- GDK_TOPLEVEL_STATE_TILED))
- return;
-
- if (surface->width <= 1 || surface->height <= 1)
- return;
-
- impl->saved_width = surface->width - impl->shadow_left - impl->shadow_right;
- impl->saved_height = surface->height - impl->shadow_top - impl->shadow_bottom;
-}
-
-static void
-_gdk_wayland_surface_clear_saved_size (GdkSurface *surface)
-{
- GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
-
- if (surface->state & (GDK_TOPLEVEL_STATE_FULLSCREEN | GDK_TOPLEVEL_STATE_MAXIMIZED))
- return;
-
- impl->saved_width = -1;
- impl->saved_height = -1;
-}
-
void
gdk_wayland_surface_update_size (GdkSurface *surface,
int32_t width,
impl->scale);
}
-static gboolean
-gdk_wayland_surface_compute_size (GdkSurface *surface)
-{
- GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
-
- if (impl->next_layout.surface_geometry_dirty)
- {
- if (GDK_IS_WAYLAND_TOPLEVEL (impl))
- configure_toplevel_geometry (GDK_WAYLAND_TOPLEVEL (surface));
- else if (GDK_IS_WAYLAND_POPUP (impl))
- configure_popup_geometry (GDK_WAYLAND_POPUP (surface));
- else if (GDK_IS_DRAG_SURFACE (impl))
- configure_drag_surface_geometry (surface);
-
- impl->next_layout.surface_geometry_dirty = FALSE;
- }
-
- return FALSE;
-}
-
static void
gdk_wayland_surface_request_layout (GdkSurface *surface)
{
unset_transient_for_exported (surface);
impl->last_sent_window_geometry = (GdkRectangle) { 0 };
-
- _gdk_wayland_surface_clear_saved_size (surface);
impl->mapped = FALSE;
}
gdk_wayland_surface_class_init (GdkWaylandSurfaceClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GdkSurfaceClass *impl_class = GDK_SURFACE_CLASS (klass);
+ GdkSurfaceClass *surface_class = GDK_SURFACE_CLASS (klass);
object_class->constructed = gdk_wayland_surface_constructed;
object_class->dispose = gdk_wayland_surface_dispose;
object_class->finalize = gdk_wayland_surface_finalize;
- impl_class->hide = gdk_wayland_surface_hide;
- impl_class->get_geometry = gdk_wayland_surface_get_geometry;
- impl_class->get_root_coords = gdk_wayland_surface_get_root_coords;
- impl_class->get_device_state = gdk_wayland_surface_get_device_state;
- impl_class->set_input_region = gdk_wayland_surface_set_input_region;
- impl_class->destroy = gdk_wayland_surface_destroy;
- impl_class->beep = gdk_wayland_surface_beep;
-
- impl_class->destroy_notify = gdk_wayland_surface_destroy_notify;
- impl_class->drag_begin = _gdk_wayland_surface_drag_begin;
- impl_class->get_scale_factor = gdk_wayland_surface_get_scale_factor;
- impl_class->set_opaque_region = gdk_wayland_surface_set_opaque_region;
- impl_class->request_layout = gdk_wayland_surface_request_layout;
- impl_class->compute_size = gdk_wayland_surface_compute_size;
+ surface_class->hide = gdk_wayland_surface_hide;
+ surface_class->get_geometry = gdk_wayland_surface_get_geometry;
+ surface_class->get_root_coords = gdk_wayland_surface_get_root_coords;
+ surface_class->get_device_state = gdk_wayland_surface_get_device_state;
+ surface_class->set_input_region = gdk_wayland_surface_set_input_region;
+ surface_class->destroy = gdk_wayland_surface_destroy;
+ surface_class->beep = gdk_wayland_surface_beep;
+
+ surface_class->destroy_notify = gdk_wayland_surface_destroy_notify;
+ surface_class->drag_begin = _gdk_wayland_surface_drag_begin;
+ surface_class->get_scale_factor = gdk_wayland_surface_get_scale_factor;
+ surface_class->set_opaque_region = gdk_wayland_surface_set_opaque_region;
+ surface_class->request_layout = gdk_wayland_surface_request_layout;
}
/* }}} */
gboolean gdk_wayland_toplevel_is_exported (GdkWaylandToplevel *wayland_toplevel);
-void configure_toplevel_geometry (GdkWaylandToplevel *toplevel);
void gdk_wayland_surface_create_xdg_toplevel (GdkWaylandToplevel *toplevel);
void gdk_wayland_surface_configure_toplevel (GdkWaylandToplevel *toplevel);
void gdk_wayland_toplevel_sync_parent (GdkWaylandToplevel *toplevel);
#define MAX_WL_BUFFER_SIZE (4083) /* 4096 minus header, string argument length and NUL byte */
-/* {{{ Utilities */
-
-static gboolean
-is_realized_shell_surface (GdkWaylandSurface *impl)
-{
- return (impl->display_server.xdg_surface ||
- impl->display_server.zxdg_surface_v6);
-}
-
-/* }}} */
/* {{{ GdkWaylandToplevel definition */
/**
GdkToplevelState set_flags;
} initial_state;
+ int saved_width;
+ int saved_height;
+
GdkToplevelLayout *layout;
int bounds_width;
int bounds_height;
G_IMPLEMENT_INTERFACE (GDK_TYPE_TOPLEVEL,
gdk_wayland_toplevel_iface_init))
+/* }}} */
+/* {{{ Utilities */
+
+static gboolean
+is_realized_shell_surface (GdkWaylandSurface *impl)
+{
+ return (impl->display_server.xdg_surface ||
+ impl->display_server.zxdg_surface_v6);
+}
+
+static void
+gdk_wayland_toplevel_save_size (GdkWaylandToplevel *toplevel)
+{
+ GdkSurface *surface = GDK_SURFACE (toplevel);
+ GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (toplevel);
+
+ if (surface->state & (GDK_TOPLEVEL_STATE_FULLSCREEN |
+ GDK_TOPLEVEL_STATE_MAXIMIZED |
+ GDK_TOPLEVEL_STATE_TILED))
+ return;
+
+ if (surface->width <= 1 || surface->height <= 1)
+ return;
+
+ toplevel->saved_width = surface->width - impl->shadow_left - impl->shadow_right;
+ toplevel->saved_height = surface->height - impl->shadow_top - impl->shadow_bottom;
+}
+
+static void
+gdk_wayland_toplevel_clear_saved_size (GdkWaylandToplevel *toplevel)
+{
+ GdkSurface *surface = GDK_SURFACE (toplevel);
+
+ if (surface->state & (GDK_TOPLEVEL_STATE_FULLSCREEN | GDK_TOPLEVEL_STATE_MAXIMIZED))
+ return;
+
+ toplevel->saved_width = -1;
+ toplevel->saved_height = -1;
+}
+
/* }}} */
/* {{{ Toplevel implementation */
toplevel->last_sent_geometry_hints.min_height = 0;
toplevel->last_sent_geometry_hints.max_width = 0;
toplevel->last_sent_geometry_hints.max_height = 0;
+
+ gdk_wayland_toplevel_clear_saved_size (toplevel);
}
static gboolean
}
}
-void
-configure_toplevel_geometry (GdkWaylandToplevel *wayland_toplevel)
+static gboolean
+gdk_wayland_toplevel_compute_size (GdkSurface *surface)
{
- GdkSurface *surface = GDK_SURFACE (wayland_toplevel);
+ GdkWaylandToplevel *wayland_toplevel = GDK_WAYLAND_TOPLEVEL (surface);
GdkWaylandSurface *wayland_surface = GDK_WAYLAND_SURFACE (wayland_toplevel);
GdkDisplay *display = gdk_surface_get_display (surface);
int bounds_width, bounds_height;
GdkGeometry geometry;
GdkSurfaceHints mask;
+ if (!wayland_surface->next_layout.surface_geometry_dirty)
+ return FALSE;
+
if (wayland_toplevel->has_bounds)
{
bounds_width = wayland_toplevel->bounds_width;
&width, &height);
gdk_wayland_surface_update_size (surface, width, height, wayland_surface->scale);
}
+
+ wayland_surface->next_layout.surface_geometry_dirty = FALSE;
+
+ return FALSE;
}
void
*/
if (saved_size && !fixed_size && was_fixed_size)
{
- width = wayland_surface->saved_width;
- height = wayland_surface->saved_height;
+ width = wayland_toplevel->saved_width;
+ height = wayland_toplevel->saved_height;
}
if (width > 0 && height > 0)
wayland_toplevel->next_layout.should_constrain = TRUE;
/* Save size for next time we get 0x0 */
- _gdk_wayland_surface_save_size (surface);
+ gdk_wayland_toplevel_save_size (wayland_toplevel);
}
else if (is_resizing)
{
{
toplevel->initial_fullscreen_output = NULL;
toplevel->shortcuts_inhibitors = g_hash_table_new (NULL, NULL);
+ toplevel->saved_width = -1;
+ toplevel->saved_height = -1;
}
static void
gdk_wayland_toplevel_class_init (GdkWaylandToplevelClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
+ GdkSurfaceClass *surface_class = GDK_SURFACE_CLASS (class);
object_class->get_property = gdk_wayland_toplevel_get_property;
object_class->set_property = gdk_wayland_toplevel_set_property;
object_class->finalize = gdk_wayland_toplevel_finalize;
+ surface_class->compute_size = gdk_wayland_toplevel_compute_size;
+
gdk_toplevel_install_properties (object_class, 1);
}
if (GDK_SURFACE_DESTROYED (surface))
return;
- _gdk_wayland_surface_save_size (surface);
+ gdk_wayland_toplevel_save_size (wayland_toplevel);
if (is_realized_toplevel (wayland_surface))
{
if (GDK_SURFACE_DESTROYED (surface))
return;
- _gdk_wayland_surface_save_size (surface);
+ gdk_wayland_toplevel_save_size (wayland_toplevel);
if (is_realized_toplevel (wayland_surface))
{
wayland_toplevel->initial_fullscreen_output = NULL;
- _gdk_wayland_surface_save_size (surface);
+ gdk_wayland_toplevel_save_size (wayland_toplevel);
if (is_realized_toplevel (wayland_surface))
{